<template>
  <el-table
    :data="tableData"
    border
    stripe
    style="width: 100%"
    :header-cell-style="headerCell"
    :cell-style="cellStyle"
  >
    <el-table-column
      type="index"
      label="序号"
      header-align="center"
      align="center"
      width="50"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="warehouseName"
      label="所属仓库"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="code"
      label="库区编号"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="name"
      label="库区名称"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="temperatureType"
      :formatter="temperatureType"
      label="温度类型"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="bearingType"
      :formatter="bearingType"
      label="承重类型"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="useType"
      :formatter="useType"
      label="用途属性"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="status"
      :formatter="statusList"
      label="库区状态"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="personName"
      label="负责人"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="phone"
      label="联系电话"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="includedNum"
      label="库区数量"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      prop="updateTime"
      label="更新时间"
      width="180"
    >
    </el-table-column>
    <el-table-column
      header-align="center"
      align="center"
      label="操作"
      width="180"
      fixed="right"
    >
      <template v-slot="{ row }">
        <el-button
          type="text"
          @click="$router.push(`/manageinfo/editarea/${row.id}`)"
          >编辑</el-button
        >
        <el-button type="text" @click="StatusShow(row)">{{
          isStatus(row.status)
        }}</el-button>
        <el-button type="text" @click="remove(row.id)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import PublicStyle from '@/mixin/publicstyle'
import EmunList from '@/constant/warehouse'
import areaEmun from '@/constant/area'
export default {
  name: 'WareTable',
  data () {
    return {}
  },
  props: {
    tableData: {
      type: Array,
      required: true
    }
  },
  mixins: [PublicStyle],
  methods: {
    // 仓库状态
    statusList (row, column, cellValue, index) {
      return EmunList.wareStatus.find(
        item => item.value === cellValue.toString()
      )?.label
    },
    // 温度类型
    temperatureType (row, column, cellValue, index) {
      return areaEmun.temperatureType.find(item => item.value === cellValue)?.label
    },
    bearingType (row, column, cellValue, index) {
      return areaEmun.bearingType.find(item => item.value === cellValue)?.label
    },
    useType (row, column, cellValue, index) {
      return areaEmun.useType.find(item => item.value === cellValue)?.label
    },
    // 删除
    remove (id) {
      this.$notify({
        title: '提示',
        message: '演示系统，不支持此操作',
        type: 'warning'
      })
    },
    // 判断按钮
    isStatus (status) {
      if (status === 0) return '启用'
      return '停用'
    },
    StatusShow (row) {
      this.$emit('StatusShow', row)
    }
  }
}
</script>

<style lang="scss" scoped>
  @import '~@/styles/elementmixin.scss';
  .el-button {
    @include el-button;
  }
</style>
